<?php
session_start();  
require_once('../Account/UserDetails.php');
require("../SocialAPI/Twitter/twitteroauth.php");  
if(!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])){
    // We've got everything we need
	echo 'We have got everything we need';
} else {
    // Something's missing, go back to square 1
   // header('Location: twitterLogin.php');
   echo 'Something is missing, go back to square 1';
}
// TwitterOAuth instance, with two new parameters we got in twitter_login.php
$twitteroauth = new TwitterOAuth('VgguNUW6GCggrDOML51w', 'y3G9Gjqu3SUzjW0RWBa1hCT566wSxlslSG9kJwQGJw', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
// Let's request the access token
$access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']);
// Save it in a session var
$_SESSION['access_token'] = $access_token;
// Let's get the user's info
$user_info = $twitteroauth->get('account/verify_credentials');
// Print user's info
//print_r($user_info);
$_SESSION["user"] = $user_info->name;
$_SESSION["userdetail"]= null;
$objUser = new UserDetails();
$objUser->UserName=$user_info->screen_name;
$objUser->FullName=$user_info->name;
$objUser->City=$user_info->location;
$objUser->Address=$user_info->location;
$_SESSION["userdetail"] = serialize($objUser);
header('Location: ..\Index.php?Register');
?>